<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@page import="eu.fsiebert.polytech.db.mediatheque.entity.Adherent"%>
<%@page import="eu.fsiebert.polytech.db.mediatheque.entity.Item"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%
    Adherent user = (Adherent)session.getAttribute("user");
    /*String pagename = request.getParameter("page");
    if(pagename == null) 
        pagename="accueil";
    <jsp:include page="<%="pages/"+pagename+".jsp"
    */
    //System.out.println(pagename);
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    //Item item;

%>
<html>
    <%@include file="../include/header.xhtml" %>
                
        <div class="art-contentLayout">
            <div class="art-sidebar1">
                <%@include file="../modules/user.jsp" %>
            </div>
            <div class="art-content">
                <div class="art-Post">
                    <div class="art-Post-body">
                        <div class="art-Post-inner">
                            <div class="art-PostContent">
                                
                                <table class="table" width="100%">
                                    <c:forEach var="item" items="${sessionScope['panier']}" varStatus="status">
                                         <tr>     
                                        <td width="33%" valign="top">
                                            <div class="art-Block">
                                                <div class="art-Block-body">
                                                    <div class="art-BlockHeader">
                                                        <div class="l"></div>
                                                        <div class="r"></div>
                                                        <div class="t">
                                                            <span>
                                                                <c:choose>
                                                                    <c:when test="${item.getTypeItem() == Livre.class}">
                                                                        Livre ${item.getLivre().getTitre()}
                                                                    </c:when>
                                                                    <c:when test="${item.getTypeItem() == Cd.class}">
                                                                        CD ${item.getCd().getTitre()}
                                                                    </c:when>
                                                                    <c:when test="${item.getTypeItem() == Dvd.class}">
                                                                        DVD ${item.getDvd().getTitre()}
                                                                    </c:when>
                                                                    <c:when test="${item.getTypeItem() ==  Magazine.class}">
                                                                        Magazine ${item.getMagazine().getTitre()}
                                                                    </c:when>
                                                                </c:choose>
 
                                                            </span>
                                                        </div>
                                                    </div>
                                                    <div class="art-BlockContent">
                                                        <div class="art-PostContent">
                                                            
                                                            <span>Référence : ${item.getRef()}</span><br />
                                                            <span>Date parution : ${dateFormat.format(item.getDateParution())}</span><br />
                                                            
                                                            <c:choose>
                                                                
                                                                <c:when test="${item.getTypeItem() == Livre.class}">
                                                                    <span>Titre : ${item.getLivre().getTitre()}</span><br />
                                                                    <span>Auteur : ${item.getLivre().getAuteur()}</span><br />
                                                                </c:when>
                                                                <c:when test="${item.getTypeItem() == Cd.class}">
                                                                    <span>Titre : ${item.getCd().getTitre()}</span><br />
                                                                    
                                                                </c:when>
                                                                <c:when test="${item.getTypeItem() == Dvd.class}">
                                                                    <span>Titre : ${item.getDvd().getTitre()}</span><br />
                                                                    
                                                                </c:when>
                                                                <c:when test="${item.getTypeItem() ==  Magazine.class}">
                                                                    <span>Titre : ${item.getMagazine().getTitre()}</span><br />
                                                                    
                                                                </c:when>
                                                            </c:choose>
                                                        </div>
                                                    </div>
                                                            
                                                </div>
                                            </div>
                                        </td>
                                     </tr>
                                    </c:forEach>
                                </table>
                                
                                 <form method="post" name="panier" action="Panier" class="form-align">
                                    <input type="hidden" name="action" value="validateCard" />
                                    <input class="art-button" type="submit" name="validateCard" value="Valider le panier" />
                                </form>
                            </div>
                            <div class="cleared"></div>
                        </div>
                    </div>
                </div>
               
            </div>
            <%@include file="../include/footer.xhtml" %>

